Skip to content

Conversation

Khartir
Copy link
Contributor

@Khartir Khartir commented Jul 24, 2025

Hope this is OK, I just cloned this rule for thecodingmachine/phpstan-safe-rule#61 and found these deprecated checks.

@Khartir Khartir force-pushed the replace_instanceof_in_JsonThrowOnErrorDynamicReturnTypeExtension branch from 1736892 to cbd6c91 Compare July 24, 2025 19:47

$secondArgType = $scope->getType($args[1]->value);
$secondArgValue = $secondArgType instanceof ConstantScalarType ? $secondArgType->getValue() : null;
$secondArgValue = count($secondArgType->getConstantScalarValues()) === 1 ? $secondArgType->getConstantScalarValues()[0] : null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$secondArgType->getConstantScalarValues() with more than one value should also be properly handled here

@Khartir Khartir force-pushed the replace_instanceof_in_JsonThrowOnErrorDynamicReturnTypeExtension branch from 2993e14 to b9665f5 Compare September 28, 2025 10:02
@Khartir Khartir force-pushed the replace_instanceof_in_JsonThrowOnErrorDynamicReturnTypeExtension branch from b9665f5 to 5099a0d Compare September 28, 2025 10:13
@ondrejmirtes ondrejmirtes merged commit 47364df into phpstan:2.1.x Sep 28, 2025
543 of 548 checks passed
@ondrejmirtes
Copy link
Member

Thank you!

@Khartir Khartir deleted the replace_instanceof_in_JsonThrowOnErrorDynamicReturnTypeExtension branch September 28, 2025 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants